<?php
namespace Application\Repository;
use Doctrine\ORM\EntityRepository;

class MessageRepository extends AbstractRepository
{
    protected $table="message";
    
    public function getByUserTo($userToId,$number = 100)
    {
    	$dql = "SELECT c FROM message c WHERE c.user_to_id=?1";
    
    	return $this->getEntityManager()->createQuery($dql)
    	->setParameter(1, $userToId)
    	->setMaxResults($number)
    	->getResult();
    }
    
    public function getByUserFrom($userFormId,$number = 100)
    {
        $dql = "SELECT c FROM message c WHERE c.user_from_id=?1";

        return $this->getEntityManager()->createQuery($dql)
                             ->setParameter(1, $userFormId)
                             ->setMaxResults($number)
                             ->getResult();
    }
}